<template>
  <div class="moreplaylist">
    <span>
      <router-link to="/recommend">
        <img src="../assets/return.png" alt="" />
      </router-link>
    </span>
    <div class="bangdan" v-for="item in showList" :key="item.id">
      <router-link :to="{ name: 'BangDan', params: { listid: item.id } }">
        <img :src="item.coverImgUrl" alt="" />
        <div class="right" v-show="item.tracks.length != 0">
          <p class="head">{{ item.name }}</p>
          <div class="des">
            <p v-for="(song, index) in item.tracks" :key="index">
              {{ song.first }} - {{ song.second }}
            </p>
          </div>
        </div>

        <div class="right" v-show="item.tracks.length == 0">
          <p class="head">{{ item.name }}</p>
          <div class="des">
            {{ item.description | emptydes }}
          </div>
        </div>
      </router-link>
    </div>
    <Loading v-if="showLoading"></Loading>
  </div>
</template>

<script>
import Loading from "@/components/Loading.vue";

export default {
  // name: MorePlayList,
  props: {},
  data() {
    return {
      morelist: [],
      limit: 10,
      showList: [],
      showLoading: true,
    };
  },
  components: {
    Loading,
  },
  created() {
    this.$http.get("/toplist/detail").then((d) => {
      this.morelist = d.data.list;
      // console.log(this.morelist);
      this.showList = this.morelist.slice(0, this.limit);
      this.showLoading = false;

      let that = this;
      window.onscroll = function () {
        var scrollTop = document.documentElement.scrollTop;
        var windowHeight = document.documentElement.clientHeight;
        var scrollHeight = document.documentElement.scrollHeight;
        if (Math.ceil(scrollTop + windowHeight) >= scrollHeight) {
          let num = that.showList.length + that.limit;
          that.showList = that.morelist.slice(0, num);
        }
      };
    });
  },
  filters: {
    emptydes(val) {
      return (val = val != null ? val : "暂无描述");
    },
  },
};
</script>

<style lang="less" scoped>
.moreplaylist {
  padding-top: 20px;
  span {
    position: fixed;
    top: 60px;
    left: 2px;
    z-index: 8;
    img {
      height: 18px;
      width: 30px;
    }
  }
  .bangdan {
    width: 92vw;
    height: 100px;
    background-color: rgba(138, 196, 208, 0.5);
    margin: 25px auto;
    border-radius: 15px;
    img {
      height: 100px;
      width: 100px;
      border-radius: 15px 0px 0px 15px;
      float: left;
    }
    .right {
      box-sizing: border-box;
      height: 100px;
      float: left;
      padding: 7px 0px 0px 12px;
      width: 60vw;
      .head {
        font-size: 18px;
        font-weight: 550;
        letter-spacing: 1px;
        white-space: nowrap;
        color: #28527a;
        overflow: hidden;
        text-overflow: ellipsis;
      }
      .des {
        overflow: hidden;
        text-overflow: ellipsis;
        height: 60px;
        display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
        color: #585858;
        p {
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
        }
      }
    }
  }
}
</style>